home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Toolbox / KeyMapTestƒ / KeyMapTst.p < prev    next >
Encoding:
Text File  |  1992-07-15  |  2.4 KB  |  89 lines  |  [TEXT/MPS ]

  1. PROGRAM KeyMapTst;
  2.  
  3. {Cameron Birse, Macintosh Technical Support}
  4. {$load KeyLoad}
  5. uses Memtypes,QuickDraw,OSIntf,ToolIntf,UWritelnWindow;
  6.    
  7.  
  8. VAR
  9.     err,i,x,y : Integer;
  10.     MyStr : str255;
  11.     myKeyMap,oldKeyMap : KeyMap;
  12.     quit,yes : boolean;
  13.     MyRect : rect;
  14.  
  15.  
  16.     {------------------------------------------------------------------------------------}
  17. {
  18.   FUNCTION SysEnvirons(versionRequested: INTEGER; VAR theWorld: SysEnvRec): OSErr;
  19.   
  20.   INLINE $205f,$301f, $A090, $3e80;
  21.   
  22.   PROCEDURE ShutDwnStart;
  23.     INLINE $3F3C,$0002,$A895;
  24.  
  25. }
  26.     {------------------------------------------------------------------------------------}
  27.  
  28.                                                     
  29. BEGIN                              {main PROGRAM}
  30.     InitGraf(@thePort);                {initialize QuickDraw}
  31.     FlushEvents(everyEvent, 0);        {call OS Event Mgr to discard any previous events}
  32.     InitWindows;                       {initialize Window Manager}
  33.     InitCursor;                        {call QuickDraw to make cursor (pointer) an arrow}
  34.  
  35. {PROCEDURE WWInit(numLines, numCharsPerLine: INTEGER);}
  36.  
  37.     WWInit(25,65);                {initialize WritelnWindow with default window}
  38.  
  39. {PROCEDURE WWNew(bounds: Rect; windowTitle: Str255; goAway: BOOLEAN; visible: BOOLEAN;
  40.                 outputFont, outputSize: INTEGER);}
  41.                 
  42.     Myrect.top := ScreenBits.bounds.top+40;
  43.     Myrect.left := ScreenBits.bounds.left+4;
  44.     Myrect.bottom := ScreenBits.bounds.bottom-4;
  45.     Myrect.right := ScreenBits.bounds.right-4;
  46.     
  47.     WWNew(MyRect, 'A Window, eh?', true, true, 1,9);
  48.  
  49.  
  50.     quit := false;
  51.     yes := false;
  52.     writeln ('KeyMap :');
  53.     for i := 0 to 127 do
  54.     begin
  55.         if myKeyMap[i] then write('1')
  56.         else write('0');
  57.         if i = 63 then writeln ('');
  58.         oldKeyMap[i] := myKeyMap[i];
  59.         if button then quit := true;
  60.     end;
  61.     writeln ('');
  62.     repeat
  63.         if button then quit := true;
  64.         GetKeys (myKeyMap);
  65.         for x := 0 to 127 do
  66.         begin
  67.             if myKeyMap[x] <> oldKeyMap[x] then 
  68.             begin
  69.                 yes := true;
  70.                 y := x;
  71.             end;
  72.         end;    
  73.         if yes then
  74.         begin
  75.             writeln ('Bit # ',y,' changed, KeyMap =');
  76.             yes := false;
  77.             for i := 0 to 127 do
  78.             begin
  79.                 if myKeyMap[i] then write('1')
  80.                 else write('0');
  81.                 if i = 63 then writeln ('');
  82.                 oldKeyMap[i] := myKeyMap[i];
  83.                 if button then quit := true;
  84.             end;
  85.             writeln (' end');
  86.         end;
  87.     until quit;    
  88.  
  89. END.